// 7.11 Danh sách CCVC hưởng bồi d
import { BasicColumn, BasicTable, FormSchema, TableAction, useTable } from "@/components/Table";
import { useTranslation } from "react-i18next";
import Toolbar from "@/components/ViewComponents/Toolbar";
import CreateAndUpdata from "./createAndUpdata";
import { useDrawer } from "@/components/Drawer";
export default function index() {
	const { t } = useTranslation();
	const schemas: FormSchema[] = [
		{
			label: t(`felix_ui.dt_date`),
			field: "dt_date",
			component: "DatePicker"
		},
		{
			label: t(`felix_ui.gruop_id`),
			field: "gruop_id",
			component: "Select",
			componentProps: {
				options: [
					{
						label: t("暂无字典接口"),
						value: 0
					}
				]
			}
		},
		{
			label: t(`felix_ui.department`),
			field: "department",
			component: "Select",
			componentProps: {
				options: [
					{
						label: "暂无字典",
						value: "0"
					}
				]
			}
		},
		{
			label: t(`felix_ui.numb_of_sheet`),
			field: "numb_of_sheet",
			component: "Select",
			componentProps: {
				options: [
					{
						label: "暂无字典",
						value: "0"
					}
				]
			}
		}
	];
	const columns: BasicColumn[] = [
		{
			title: t("felix_ui.sq_numb"),
			width: 100,
			// dataIndex: "sq_numb",
			render: (text, record, index) => index * 1 + 1 // 设置序号
		},
		{
			title: t(`felix_ui.patient_code`),
			dataIndex: "patient_code"
		},
		{
			title: t(`felix_ui.full_name`),
			dataIndex: "full_name"
		},
		{
			title: t(`felix_ui.position`),
			dataIndex: "position"
		},
		{
			title: t(`felix_ui.JobDescription`),
			dataIndex: "JobDescription"
		},
		{
			title: t(`felix_ui.from`),
			dataIndex: "from"
		},
		{
			title: t(`felix_ui.to`),
			dataIndex: "to"
		},
		{
			title: t(`felix_ui.numberOfHours`),
			dataIndex: "numberOfHours"
		},
		{
			title: t(`felix_ui.numberOfDay`),
			dataIndex: "numberOfDay"
		},
		{
			title: t(`felix_ui.level`),
			dataIndex: "level"
		},
		{
			title: t(`felix_ui.grp_notes`),
			dataIndex: "notes"
		},
		{
			title: t("felix_ui.action"),
			key: "action",
			fixed: "right",
			render: (_, record) => (
				<TableAction
					actions={[
						{
							label: t("felix_ui.edit"),
							onClick: handleEdit.bind(record)
						},
						{
							label: t("felix_ui.delete"),
							popConfirm: {
								title: t("felix_ui.delMessage"),
								confirm: handleDelete.bind(record.patient_code)
							}
						}
					]}
				/>
			)
		}
	];
	const getInfo = () => {
		let arr: any = [
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			},
			{
				patient_code: "adefgsfdda",
				full_name: "嘟嘟嘟",
				position: "2025",
				JobDescription: "green",
				numberOfDay: "green",
				numberOfHours: "lundun",
				from: "USA",
				to: "15",
				level: "32",
				notes: "4354"
			}
		];
		return arr;
	};
	const [registerTable, { reload }] = useTable({
		// api: productApi.getproductPage,
		dataSource: getInfo(),
		columns,
		formConfig: {
			labelWidth: 120,
			labelWrap: true,
			schemas,
			showActionButtonGroup: true,
			showAdvancedButton: false,
			baseColProps: { span: 6 },
			actionColOptions: { span: 24 }
		},
		bordered: true,
		useSearchForm: true
		// searchInfo: {
		// 	bizType: "2"
		// }
		// afterFetch: (res: any) => {
		// 	return res.map((item: any) => mergeObjects(item, item.bloods));
		// }
	});
	const handleEdit = (record: any) => {
		openDrawer(true, {
			reload,
			record,
			isUpdated: true
		});
	};
	//删除角色
	const handleDelete = async (id: any) => {
		console.log("id", id);
		// // 发起删除
		// const res = await productApi.deleteproduct(id, "2");
		// reload();
		// if (!res) return message.error(t("viewComponents.patientInformation.deleteFailed"));
		// message.success(t("viewComponents.patientInformation.deleteSuccessfully"));
	};
	const handlerToolbarAction = async (key: string) => {
		switch (key) {
			case "add":
				openDrawer(true, {
					reload,
					isUpdated: false
				});
				break;
		}
	};
	const [registerDrawer, { openDrawer }] = useDrawer();
	return (
		<div className="page">
			<div className="page-content">
				<BasicTable register={registerTable}></BasicTable>
				<CreateAndUpdata register={registerDrawer}></CreateAndUpdata>
			</div>
			<Toolbar action={handlerToolbarAction} btnList={["add"]} />
		</div>
	);
}
